<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<!-- 时间倒计时功能，倒计时10秒后，跳转到百度。页面要动态显示剩余时间 -->
		 <button>跳转百度</button>
		    <div></div>
		 
		    <script>
		        var btn = document.querySelector('button');
		        var div = document.querySelector('div')
		            btn.addEventListener('click', function() {
		                var times = 10;
		                setInterval(function() {
		                    if (times == 0) {
		                        location.href = 'http://www.baidu.com';
		                        times = 10;
		                    } else {
		                        div.innerHTML = '还剩' + times + '秒自动跳转'
		                        times--;
		                    }
		 
		            }, 1000)
		        })
		        // 五秒后直接跳转
		        var times = 10
		        setInterval(function() {
		            if (times == 0) {
		                location.href = 'http://www.baidu.com';
		                times = 10;
		            } else {
		                div.innerHTML = '还剩' + times + '秒自动跳转'
		                times--;
		            }
		 
		        }, 1000)
		    </script>
	</body>
</html>